package com.td.module.produce.dal.mysql.info;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.produce.controller.admin.info.vo.InfoExportReqVO;
import com.td.module.produce.controller.admin.info.vo.InfoPageReqVO;
import com.td.module.produce.dal.dataobject.info.InfoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 生产管理基础信息 Mapper
 *
 * @author 吴佰强
 */
@Mapper
public interface InfoMapper extends BaseMapperX<InfoDO> {

    default PageResult<InfoDO> selectPage(InfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InfoDO>()
                .eqIfPresent(InfoDO::getCropSpecie, reqVO.getCropSpecie())
                .likeIfPresent(InfoDO::getCropVarieties, reqVO.getCropVarieties())
                .eqIfPresent(InfoDO::getLandCode, reqVO.getLandCode())
                .eqIfPresent(InfoDO::getPlantArea, reqVO.getPlantArea())
                .likeIfPresent(InfoDO::getSeedName, reqVO.getSeedName())
                .eqIfPresent(InfoDO::getUsage, reqVO.getUsage())
                .eqIfPresent(InfoDO::getGrowthId, reqVO.getGrowthId())
                .eqIfPresent(InfoDO::getPlantStandards, reqVO.getPlantStandards())
                .eqIfPresent(InfoDO::getPlantEnvironment, reqVO.getPlantEnvironment())
                .betweenIfPresent(InfoDO::getPlantTime, reqVO.getPlantTime())
                .betweenIfPresent(InfoDO::getHarvestTime, reqVO.getHarvestTime())
                .betweenIfPresent(InfoDO::getColonizationTime, reqVO.getColonizationTime())
                .eqIfPresent(InfoDO::getPlantStatus, reqVO.getPlantStatus())
                .betweenIfPresent(InfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InfoDO::getId));
    }

    default List<InfoDO> selectList(InfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InfoDO>()
                .eqIfPresent(InfoDO::getCropSpecie, reqVO.getCropSpecie())
                .likeIfPresent(InfoDO::getCropVarieties, reqVO.getCropVarieties())
                .eqIfPresent(InfoDO::getLandCode, reqVO.getLandCode())
                .eqIfPresent(InfoDO::getPlantArea, reqVO.getPlantArea())
                .likeIfPresent(InfoDO::getSeedName, reqVO.getSeedName())
                .eqIfPresent(InfoDO::getUsage, reqVO.getUsage())
                .eqIfPresent(InfoDO::getGrowthId, reqVO.getGrowthId())
                .eqIfPresent(InfoDO::getPlantStandards, reqVO.getPlantStandards())
                .eqIfPresent(InfoDO::getPlantEnvironment, reqVO.getPlantEnvironment())
                .betweenIfPresent(InfoDO::getPlantTime, reqVO.getPlantTime())
                .betweenIfPresent(InfoDO::getHarvestTime, reqVO.getHarvestTime())
                .betweenIfPresent(InfoDO::getColonizationTime, reqVO.getColonizationTime())
                .eqIfPresent(InfoDO::getPlantStatus, reqVO.getPlantStatus())
                .betweenIfPresent(InfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InfoDO::getId));
    }

}
